#include <algorithm>
#include <cstdint>
#include <iostream>
#include <limits>
#include <vector>

using ll = int64_t;

std::vector<ll> t;
std::vector<ll> nums;

ll create(ll l, ll r, ll idx) {
    if (l == r) {
        t[idx] = nums[l];
        return t[idx];
    }
    ll mid = (l + r) / 2;
    t[idx] = std::min(create(l, mid, 2 * idx + 1), create(mid + 1, r, 2 * idx + 2));
    return t[idx];
}

void update(ll l, ll r, ll idx, ll pos, ll val) {
    if (l == r) {
        t[idx] = val;
        return;
    }
    ll mid = (l + r) / 2;
    if (pos <= mid) {
        update(l, mid, 2 * idx + 1, pos, val); 
    } else {
        update(mid + 1, r, 2 * idx + 2, pos, val);
    }
    t[idx] = std::min(t[2 * idx + 1], t[2 * idx + 2]);
}

ll query(ll cur,ll ql,ll qr,ll l,ll r){
    if(qr<l || r<ql)return std::numeric_limits<ll>::max();
    if(ql<=l && r<=qr)return t[cur];
    ll mid = (l+r)/2;
    return std::min(
        query(cur*2+1, ql, qr, l, mid),
        query(cur*2+2, ql, qr, mid+1, r)
    );
}

int main(){
    // 区间min 单点修改
    ll n;
    std::cin>>n;
    t.resize(4*n);
    nums.resize(n);
    for(ll i=0; i<n; i++){
        std::cin>>nums[i];
    }
    create(0, n - 1, 0);
    ll q;
    std::cin>>q;
    while(q--){
        ll idx, val;
        std::cin>>idx>>val;
        idx--;
        update(0, n - 1, 0, idx, val);
        std::cout << t[0] << "\n";
    }
    std::cin>>q;
    while(q--){
        ll l,r;
        std::cin>>l>>r;
        l++,r++;
        std::cout<<query(0, l, r, 0, n-1)<<'\n';
    }
}